import request from '@/utils/request';
export const getArticleApi = (channel_id: number, timestamp = Date.now()) => {
  return request({
    url: `/v1_0/articles`,
    params: {
      channel_id,
      timestamp,
    },
  });
};

//获取文章详情
export const getArticleDetailApi = (article_id: string) => {
  return request({
    url: `/v1_0/articles/${article_id}`,
  });
};

//给文章点赞
export const likeArticleApi = (article_id: string) => {
  return request({
    url: `/v1_0/article/likings`,
    method: 'POST',
    data: {
      target: article_id,
    },
  });
};
//取消文章点赞
export const unlikeArticleApi = (article_id: string) => {
  return request({
    url: `/v1_0/article/likings/${article_id}`,
    method: 'DELETE',
  });
};
//收藏文章
export const collectArticleApi = (article_id: string) => {
  return request({
    url: `/v1_0/article/collections`,
    method: 'POST',
    data: {
      target: article_id,
    },
  });
};
//取消收藏文章
export const uncollectArticleApi = (article_id: string) => {
  return request({
    url: `/v1_0/article/collections/${article_id}`,
    method: 'DELETE',
  });
};

//关注用户
export const followUserApi = (target: string) => {
  return request({
    url: `/v1_0/user/followings`,
    method: 'POST',
    data: {
      target,
    },
  });
};

//取消关注用户
export const unfollowUserApi = (target: string) => {
  return request({
    url: `/v1_0/user/followings/${target}`,
    method: 'DELETE',
  });
};
